﻿//////////////////////////////////////////////////////////////////
//
// Entity.cs
//
// Copyright (c) 2012 Dan Pike. All rights reserved
//
// Refer to license.txt for any license restrictions.
// 
using Logger4Net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Entities
{
   public abstract class Entity
   {
      ////////////////////////////////////////////////////////////////////////
      //
      protected Entity(World world)
      {
         dirty_ = false;
         world_ = world;
      }

      //////////////////////////////////////////////////////////////////////////
      //
      public World world
      {
         get { return world_; }
         set { world_ = value; }
      }

      ////////////////////////////////////////////////////////////////////////
      //
      public virtual string name
      {
         get { return name_; }
         set { name_ = value; }
      }

      ////////////////////////////////////////////////////////////////////////
      //
      public virtual double count
      {
         get { return count_; }
         set { count_ = value; }
      }

      ////////////////////////////////////////////////////////////////////////
      //
      public virtual bool dirty
      {
         get { return dirty_; }
         set { dirty_ = value; }
      }

      //////////////////////////////////////////////////////////////////////////
      //
      public override int GetHashCode()
      {
         // Everything that can be stored in hashed tables needs to have an
         // entry in the HashCodes enum; this is to optimise the lookups.
         string exception = string.Format("Type '{0}' is an Entity but has not "
            + "defined a GetHashCode() method", GetType().FullName);
         throw new NotImplementedException(exception);
      }

      ////////////////////////////////////////////////////////////////////////
      //
      protected static Logger logger_ = new Logger(typeof(Entity));
      private World world_;
      private string name_;
      private double count_;
      private bool dirty_;

      protected enum HashCodes
      {
         None,
      
         // Cities
         Aalborg, Ahus, Bergen, Berlin, Boston, Bremen, Breslau, Bruges, Cologne,
         Danzig, Edinburgh, Erfurt, Flensburg, Gothenburg, Groningen, Haarlem,
         Hamburg, Helsinki, Kaunas, Konigsburg, London, Lubeck, Malmo, Minden,
         Naestved, Nimwegen, Novgorod, Oslo, Posen, Reval, Riga, Ripen, Rostock,
			Scarborough, Stavanger, Stettin, Stockholm, Thorn, Visby, Warsaw,
			
         // Factories
         Beekeeper, Brewery, Claypit, Dairy, GrainFarm, HempFarm, HuntingLodge,
         MeadBrewery, Pitchmaker, Saltworks, Sawmill, SheepFarm, Smelter, Smokehouse,
         StockFarm, Tailor, Toolworks, Weaver, Winery,

         // Materials
         Beer, Bricks, Cheese, Cloth, Clothing, Fish, Grain, Hemp, Honey, Ingot,
         Mead, Meat, Pelts, Pitch, Salt, Spices, Tools, Wine, Wood, Wool,

         // Transporters
         RiverCog, Hulk, HanseaticCog, Crayer, Cog, Snaikka, Caravel,

         // Miscellaneous
         Convoy,
      }
   }
}
